package com.example.circleview;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * 自定义View
 * 实现边框圆角
 * 非图片圆角
 */
public class MyView extends View{
    public MyView(Context context) {
        super(context);
    }

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int r=getMeasuredWidth()/2;
        int cx=getLeft()+r;
        int cy=getTop()+r;
        Paint paint=new Paint();
        paint.setColor(Color.RED);
        canvas.drawCircle(cx,cy,r,paint);
    }

    public MyView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

}
